@extends('layouts.default') @section('main')
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('topic/index')}}" class="tip-bottom">专题管理</a>
                <a href="{{url('topicphoto/index?id='.$topic_id)}}" class="tip-bottom">图片管理</a>
                <a href="#" class="current">编辑图片</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>编辑图片</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('topicphoto/edit')}}" method="post" id="adForm" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label">专题图片 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="photo"
                                               placeholder="新增一个图片" value="{{$list->photo}}"  />
                                        <img src="{{$list->photo}}" width="120px" name="photo" height="120px"/>
                                        <a href="javascript:void(0);" id="uploadWxphotoBtn"  onclick="javascript:openBrowse('uploadWxphotoBtn','uploadWxphoto');">点击上传</a>
                                        <input type="file" id="uploadWxphoto" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadWxphoto','photo')"/>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">图片描述 :</label>
                                    <div class="controls">
                                        <textarea name="description" placeholder='图片描述' style="width:610px; height:100px">{{$list->description}}</textarea>                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort" placeholder="sort" value="{{$list->sort}}" />
                                    </div>


                                    <div class="control-group ">
                                        <label class="control-label"><span class="redD">*</span>对应的关联 :</label>
                                        <div class="controls ">
                                            <select  name="topic_post_id" class=" span11" >
                                                <option value="">请选择</option>
                                                @foreach($topics as $k=>$v)
                                                    <option value="{{$v->id}}" @if($list->topic_post_id==$v->id)selected @endif > {{$v->subject}}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>


                                    {{--<div class="control-group" id="add">--}}
                                    {{--<label class="control-label"></label>--}}
                                    {{--<div class="controls">--}}
                                    {{--<button type="button" style="float:right; margin-right:50px; margin-bottom:10px" id="addphoto" class="btn btn-success">继续新增图片</button>--}}
                                    {{--</div>--}}
                                    {{--<div style="clear:both;"></div>--}}
                                    {{--</div>--}}

                                    <input type="hidden" class="span11" name="formType" value="create" />
                                    <div class="form-actions">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <input type="hidden" name="topic_id" value="{{$topic_id}}">
                                        <input type="hidden" name="id" value="{{$list->id}}">
                                        <button type="button" id="doSave" class="btn btn-success">编辑</button>
                                    </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        //        var n = 1;
        //        $("#addphoto").click(function(){
        //            n++;
        //            var html = '';
        //            html +='<div class="control-group">';
        //            html +='<label class="control-label">专题图片 :</label>';
        //            html +='<div class="controls">';
        //            html +='<input type="hidden" class="span11" name="topicphoto'+n+'" placeholder="新增一个图片" />';
        //            html +='<img src="" width="120px" name="topicphoto'+n+'" height="120px"/>';
        //            html +='<a href="javascript:void(0);" id="uploadPhotoBtn"  onclick="javascript:openBrowse(\'upload'+n+'PhotoBtn\',\'uploadPhoto'+n+'\');">点击上传</a>';
        //            html +='<input type="file" id="uploadPhoto'+n+'" style="display:none" name="myfile" size="10" onchange="fileUpload(\'uploadPhoto'+n+'\',\'topicphoto'+n+'\')"/>';
        //            html +='</div>';
        //            html +='</div>';
        //            html +='<div class="control-group">';
        //            html +='<label class="control-label">图片描述 :</label>';
        //            html +='<div class="controls">';
        //            html +='<textarea name="content'+n+'" placeholder="图片描述"  style="width:610px; height:100px"></textarea>';
        //            html +='</div>';
        //            html +='</div>';
        //            html +='<div class="control-group">';
        //            html +='<label class="control-label">排序 :</label>';
        //            html +='<div class="controls">';
        //            html +='<input type="text" class="span11" name="sort'+n+'" placeholder="sort"  />';
        //            html +='</div>';
        //            $("#add").before(html);
        //        });
        $("#doSave").click(function(){
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>

    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
@stop
